#include <exception>
#include <stdexcept>
#include <string>

class Error : public std::runtime_error
{
public:

    Error(int error, const char* fmt, ...)
    #ifdef __GNUC__
    __attribute__ ((format (printf, 3, 4)))
    #endif
    ;

    virtual ~Error() throw()
    {}

    inline int error() const throw()
    {  return m_error; }

    const char* what() const throw()
    {  return m_msg.c_str(); }

private:

    static std::size_t const buffer_length;

    int m_error;

    std::string m_msg;
};

class Exception : public std::exception
{
public:

    Exception(const char* fmt, ...)
    #ifdef __GNUC__
    __attribute__ ((format (printf, 2, 3)))
    #endif
    ;

    virtual ~Exception() throw()
    {}

    const char* what() const throw()
    {  return msg.c_str(); }

private:

    static std::size_t const buffer_length;

    std::string msg;

};
